﻿package {
	import flash.display.*;
	import flash.events.*;
	public class Bubble extends MovieClip {
		private var _arr:Array;

		private var randomBubble:MovieClip;

		public function Bubble() {
			init();
		}
		private function init() {

			var a:A = new A();
			var b:B = new B();
			var c:C = new C();
			var d:D = new D();
			var e:E = new E();
			var f:F = new F();
			var g:G = new G();
			_arr = new Array(a,b,c,d,e,f,g);
			randomBubble = _arr[Math.floor(Math.random()*7)];
			
			randomBubble.scaleX = 1.1;
			randomBubble.scaleY = 1.1;
			addChild(randomBubble);

		}
		public function getSuroundPosition():Array{
			var X:Number = this.x;
			var Y:Number = this.y;
			var arr0:Array = [X-15,Y-30];
			var arr1:Array = [X+15,Y-30];
			var arr2:Array = [X+30,Y];
			var arr3:Array = [X+15,Y+30];
			var arr4:Array = [X-15,Y+30];
			var arr5:Array = [X-30,Y];
			var arr:Array = [arr0,arr1,arr2,arr3,arr4,arr5];
		    return arr;
		}
		public function getDistance(array:Array):Number{
			var dx:Number = array[0] - this.x;
			var dy:Number = array[1] - this.y;
			var dis:Number = Math.sqrt(dx*dx + dy*dy);
			return dis;
		}
			
		public function changeColor():void {
			randomBubble = null;
			randomBubble = _arr[Math.floor(Math.random()*5)];
		}
		public function checkType():Number{
			var num:Number;
			if (randomBubble is A){
				num = 1;
			}else if(randomBubble is B){
				num = 2;
			}else if(randomBubble is C){
				num = 3;
			}else if(randomBubble is D){
				num = 4;
			}else if(randomBubble is E){
				num = 5;
			}else if (randomBubble is F){
				num = 6;
			}else if (randomBubble is G){
				num = 7;
			}
			
			return num;
		}
	}
}